package com.bigdata.appliance.controller;

import com.bigdata.appliance.entity.Address;
import com.bigdata.appliance.service.IAddressService;
import com.bigdata.appliance.vo.req.AddAddressReqVO;
import com.bigdata.appliance.vo.req.EditAddressReqVO;
import com.bigdata.appliance.vo.req.GetUserAddressListReqVO;
import com.bigdata.appliance.vo.req.SetDefaultAddressReqVO;
import com.bigdata.appliance.vo.resp.GetUserAddressLIstRespVO;
import io.swagger.annotations.Api;
import io.swagger.annotations.ApiOperation;
import org.springframework.transaction.annotation.EnableTransactionManagement;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;

import javax.annotation.Resource;
import javax.validation.Valid;
import java.util.List;

/**
 * <p>
 * 用户地址表 前端控制器
 * </p>
 *
 * @author appliance-shop
 * @since 2023-12-23
 */
@RestController
@RequestMapping("/api")
@Api(value = "AddressController", tags = {"地址接口"})
@EnableTransactionManagement
public class AddressController {

    @Resource
    private IAddressService iAddressService;

    @PostMapping("/uniApp/address/add")
    @ApiOperation(value = "添加地址接口")
    public void addAddress(@RequestBody @Valid AddAddressReqVO vo) {
        iAddressService.addAddress(vo);
    }

    @PostMapping("/uniApp/address/edit")
    @ApiOperation(value = "修改地址接口")
    public void editAddress(@RequestBody @Valid EditAddressReqVO vo) {
        iAddressService.editAddress(vo);
    }

    @PostMapping("/uniApp/address/default")
    @ApiOperation(value = "设置默认地址接口")
    public void setDefaultAddress(@RequestBody @Valid SetDefaultAddressReqVO vo) {
        iAddressService.setDefaultAddress(vo);
    }

    @PostMapping("/uniApp/address")
    @ApiOperation(value = "获取用户地址接口")
    public GetUserAddressLIstRespVO getUserAddress(@RequestBody @Valid GetUserAddressListReqVO vo) {
        return iAddressService.getUserAddress(vo);
    }
}
